package com.icinfo.cloud.provider.common.enums;

import cn.hutool.core.util.StrUtil;
import com.icinfo.cloud.provider.common.constant.Constant;
import lombok.Getter;

/**
 * 检查-单位类型
 * @date 2020/3/31
 * @Version V1.0
 **/
@Getter
public enum CheckOrgEntityCategoryEnum {
    QY("91","企业"),
    GTH("92","个体户"),
    NZS("93","农专社"),
    JG("11","机关"),
    SYDW("12","事业单位"),
    SHTT("51","社会团体"),
    MBFQDW("52","民办非企单位"),
    JJH("53","基金会"),
    LSZYJG("31","律师执业机构"),
    SFGLQTJG("39","司法管理其它机构"),
    ZJHDCS("71","宗教活动场所"),
    CMWYH("54","村民委员会"),
    CMJWH("55","居民委员会"),
    JTJJZZ("N1","集体经济组织");


    private String key;

    private String value;

    CheckOrgEntityCategoryEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    /**
     * @MethodName: getKeyByValue
     *  根据value获取key
      * @param value
     * @Return java.lang.String
     * @author 彭德志
     * @date 2020/3/31
    **/
    public static  String getKeyByValue(String value){
        if(StrUtil.isBlank(value)){
            return null;
        }
        for (int i = 0; i < CheckOrgEntityCategoryEnum.values().length; i++){
            String content = CheckOrgEntityCategoryEnum.values()[i].value;
            if(content.equals(value)){
                return CheckOrgEntityCategoryEnum.values()[i].key;
            }
        }
        return null;
    }


    /**
     * @MethodName: getKeyByValue
     *  根据value获取key
     * @param key
     * @Return java.lang.String
     * @author 彭德志
     * @date 2020/3/31
     **/
    public static String getValueByKey(String key){
        if(StrUtil.isBlank(key)){
            return null;
        }
        for (int i = 0; i < CheckOrgEntityCategoryEnum.values().length; i++){
            if(CheckOrgEntityCategoryEnum.values()[i].key.equals(key)){
                return CheckOrgEntityCategoryEnum.values()[i].value;
            }
        }
        return null;
    }

    /**
     * 获取处罚对应的单位类型
     * @param key
     * @return
     */
    public static String getPunishEntTypeByKey(String key){
        if (CheckOrgEntityCategoryEnum.QY.getKey().equals(key)){
            // 对应处罚单位类型-法人
            return Constant.STRING_1;
        }else if (CheckOrgEntityCategoryEnum.GTH.getKey().equals(key)){
            // 对应处罚单位类型-个体户
            return Constant.STRING_2;
        }else {
            // 对应处罚单位类型-其他组织
            return Constant.STRING_3;
        }
    }



}
